
/**
 * @Author 天下无敌
 * @Date 
 * @AIDE AIDE+ 
 */
package com.ecs.core.gsystem.player;
import com.artemis.BaseSystem;
import com.artemis.ComponentMapper;
import com.ecs.core.EntityBuilder;
import com.ecs.core.debug.Debug;
import com.ecs.core.gsystem.AssetsSystem;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.ecs.core.utils.JsonAnimation;
import com.ecs.core.utils.AnimationType;
import com.ecs.core.GameContext;
import com.ecs.core.components.attribute.Transform;
import com.ecs.core.other.state.IdleState;

public class PlayerDataSystem extends BaseSystem
{
	public static final String TAG = "PlyaerDataSystem";
	
	private AssetsSystem asset;
	private int player_id;
	private ComponentMapper<Transform> tramsForms;
	
	@Override
	protected void initialize()
	{
		super.initialize();
		ObjectMap<String,Animation<TextureRegion>> ans = JsonAnimation.loadAnimations("animations/playerAnimation.json",asset.getAsset());
		player_id = EntityBuilder.init(world)
		.Scale(1,1)
		.Pos(16,16)
		.EntityState(new IdleState())
		.Movement(4f)
		.Animation(ans,AnimationType.IDLEDOWN)
		.Sprite(ans.get(AnimationType.IDLEDOWN).getKeyFrame(0),GameContext.LAYERE_3)
		.getId();	
		Debug.log(TAG,String.format("Initialize the player. The player ID is %d",player_id));
	}
	
	public float getPlayerCenterX(){
		Transform t = tramsForms.get(player_id);
		return t.getPosX() + (t.getScaleX() * 0.5f);
	}
	public float getPlayerCenterY(){
		Transform t = tramsForms.get(player_id);
		return t.getPosY() + (t.getScaleY() * 0.5f);
	}

	@Override
	protected void processSystem()
	{
	}
	
	public int getId(){
		return player_id;
	}
}
